'use strict';(function(a){window.addEventListener("load",function(){a("body").on("click","a.wpf_lightbox",function(b){b.preventDefault();b.stopPropagation();var c=a(this);a.ajax({url:this,success:function(d){if(d){var e=c.attr("title"),h=c.data("class"),m=c.data("top");b.preventDefault();a(document).on("keyup",g);var k="wpf_"+Math.random().toString(36).substr(2,9);d='<div id="'+k+'" class="wpf_admin_lightbox wpf_interface"><div class="wpf_lightbox_title">'+e+'</div><a href="#" class="wpf_close_lightbox">\u00d7</a><div id="wpf_lightbox_container"><div class="wpf_lightbox_inner">'+
d+'</div></div></div><div class="wpf_overlay"></div>';a("body").append(d);m||(m=100);h&&a("#"+k).addClass(h);a.event.trigger("WPF.openlightbox",[b,k]);a("#"+k).nextAll(".wpf_overlay").show();a("#"+k).show().css("top",l()).animate({top:m},800);a("#"+k).find(".wpf_close_lightbox").on("click",f);h=a("#wpf-import-btn");h.length&&wpf_import(h)}}})}).on("click",".wpf_delete",function(b){if(confirm(wpf_js.template_delete)){var c=a(this),d=c.closest("table");a.ajax({url:this,dataType:"json",beforeSend:function(){d.addClass("wpf_save")},
complete:function(){d.removeClass("wpf_save")},success:function(e){e&&"1"==e.status&&c.closest("tr").remove()}})}b.preventDefault()}).on("click",".open_media_uploader_image",function(b){var c=a(this).closest(".wpf_background_image"),d=wp.media({frame:"post",state:"insert",multiple:!1});d.open();d.on("insert",function(){var e=d.state().get("selection").first().toJSON();c.find("input").val(e.url);c.find("img").attr("src",e.url);c.addClass("has-image")});b.preventDefault()}).on("click",".remove-background",
function(b){var c=a(this).closest(".wpf_background_image");1==confirm("Remove background image?")&&(c.find("input").val(""),c.find("img").attr("src",""),c.removeClass("has-image"));b.preventDefault()})},{once:!0,passive:!0});var l=function(){var b=document;return Math.max(Math.max(b.body.scrollHeight,b.documentElement.scrollHeight),Math.max(b.body.offsetHeight,b.documentElement.offsetHeight),Math.max(b.body.clientHeight,b.documentElement.clientHeight))},g=function(b){27===b.keyCode&&(b.preventDefault(),
f(b))},f=function(b){b.preventDefault();a(document).off("keyup",g);var c=a(this).closest(".wpf_admin_lightbox");a.event.trigger("WPF.close_lightbox",this);c.animate({top:l()},800,function(){c.next(".wpf_overlay").remove();c.remove()})}})(jQuery);
function wpf_import(a){var l=a.attr("id").replace("plupload-upload-ui",""),g=[],f=a.closest("form"),b=f.find(".wpf_error");g=f.data("plupload");g.browse_button=l;g.container=a.closest("form").attr("id");g.file_data_name=a.data("name")?a.data("name"):g.file_data_name;g.multipart_params={nonce:"",action:""};a.data("formats")&&(g.filters=a.data("formats"));var c=new plupload.Uploader(g);c.init();c.bind("FilesAdded",function(d,e){if(!a.data("confirm")||confirm(a.data("confirm")))c.settings.multipart_params.action=
f.find('input[name="action"]').val(),c.settings.multipart_params.nonce=f.find('input[name="nonce"]').val(),d.refresh(),d.start(),f.addClass("wpf_save")});c.bind("Error",function(d,e){f.removeClass("wpf_save");e.message&&b.text(e.message)});c.bind("FileUploaded",function(d,e,h){h?(d=JSON.parse(h.response),d.error?(f.removeClass("wpf_save"),b.text(d.error)):d.success&&(setTimeout(function(){f.removeClass("wpf_save")},1500),window.location.reload())):f.removeClass("wpf_save")})};
